<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>富时A50</title>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/own.css"/>
    <script type="text/javascript" src="../../js/mui.min.js" ></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<link rel="stylesheet" href="../../css/recharge.css" />
	<script src="../../js/jquery-1.11.3.js"></script>
	<script>
		mui.init();
		var paramListAll=null;
		mui.plusReady(function(){
			
			loadCss();
    		function loadCss(){
    			var width=window.innerWidth;
				$(".sc_listsc").css({
					"margin-top":"5px",
					"padding":"0px 5px",
				});
				$(".mui-table-view-cell div:nth-child(1)").css({
					"width":"110px ",
				});
				$(".mui-table-view-cell div:nth-child(2)").css({
					"width":width-120+"px ",
				});
				$(".sc_listscStyle div:nth-child(1)").css({
						"width":"85px ",
				});
				$(".sc_listscStyle div:nth-child(2)").css({
						"width":width-95+"px ",
				})
			}
			//初始化监听头部和底部事件
  			var paramUrl={
				url:"../login/login.html"
			}
  			//获取富时A50数据
  			mui.app_request("/ftrade/params",{
  				"businessType":0
  			},function(result){
  				 
  				if(!mui.isnull(result.data)){
  					paramListAll=result.data.paramList;
  					mui.each(paramListAll,function(i,item){
  						
  						//动态创建开仓手数子元素
  						createtranLevers(item);
  						//读取第一个默认的集合详细数据 
  						if(i==0){
  							setParams(item);
  							var lis=document.getElementById("trade_num").getElementsByTagName("li");
  						mui.each(lis,function(i,item){
  							if(i==0){
  								item.setAttribute("class","mui-table-view-cell mui-media mui-col-xs-3 on");
  							}  
  						});
  						}
  					});
  					//读取主力合约数据
  					mui.each(result.data.contractList,function(i,item){
  						setmainContract(item);
  					});
  					
  					 			
  					mui("#trade_num").on("tap","li",function(){
  						var lis=document.getElementById("trade_num").getElementsByTagName("li");
  						mui.each(lis,function(i,item){
  							if(item.getAttribute("class")=="mui-table-view-cell mui-media mui-col-xs-3 on"){
  								item.setAttribute("class","mui-table-view-cell mui-media mui-col-xs-3");
  							}
  						});
  						this.setAttribute("class","mui-table-view-cell mui-media mui-col-xs-3 on");
  						var tranLever_num=parseInt(this.innerHTML);
  						//切换详细数据
  						mui.each(paramListAll,function(i,item){
  							if(!mui.isnull(tranLever_num)&&tranLever_num==item.tranLever){
  								setParams(item);
  							}
  						});
  				});
  		
  					
  					
  				}
  			},function(result){
  				mui.toast(result.message);
  				return;
  			},paramUrl)
//			document.getElementById("backPage").addEventListener("tap",function(){
//				mui.openWindow({
//					url:"../../home.html",
//					id:"home.html"
//				})
//			});
			document.getElementById("back").addEventListener("tap",function(){
		    			mui.back();
		    });
  			document.getElementById("openPay").addEventListener("tap",function(){
//				this.setAttribute('disabled','disabled')  //禁用按钮
  				openPays();
  			});
  			
  			/*document.getElementById("telservice").addEventListener("tap",function(){
  				mui.callService();
  			});*/
  			
  			document.getElementById("tran_info").addEventListener("tap",function(){
  				mui.openWindow("../agree/a50ru.html");
  			});
  			
  			document.getElementById("cn_info").addEventListener("tap",function(){
  				mui.openWindow("../agree/a50.html");
  			});
  			
 
  			
		});
		
		
		function createtranLevers(ParamsList){
			var trade_num=document.getElementById("trade_num");
			var li=document.createElement("li");
			li.setAttribute("class","mui-table-view-cell mui-media mui-col-xs-3");
			li.innerHTML=ParamsList.tranLever+"手";
			trade_num.appendChild(li);
		};
		
		function setParams(ParamsList){
			document.getElementById("traderBond").innerHTML="¥"+tzdr.moneyUtils.formatCurrency(ParamsList.traderBond);
			document.getElementById("traderTotal").innerHTML=tzdr.moneyUtils.formatCurrency(ParamsList.traderTotal)+"美元";
			document.getElementById("lineLoss").innerHTML=tzdr.moneyUtils.formatCurrency(ParamsList.lineLoss)+"美元";
			document.getElementById("paymentMoney").innerHTML=tzdr.moneyUtils.formatCurrency(ParamsList.traderBond)+"元";
			if(mui.isnull(ParamsList.manageFee)){
				document.getElementById("manageFee").innerHTML="免费";
			}else{
				document.getElementById("manageFee").innerHTML=ParamsList.manageFee+"元";
			}
			
			document.getElementById("tranFees").innerHTML=ParamsList.tranFees;
		};
		
		function setmainContract(contractList){
			document.getElementById("mainContract").innerHTML=contractList.mainContract;
		};
		
		function openPays(){
			var traderBond=document.getElementById("traderBond").innerHTML;
			var lis=document.getElementById("trade_num").getElementsByTagName("li");
			var trade_leve=null;
				mui.each(lis,function(i,item){
					if(item.getAttribute("class")=="mui-table-view-cell mui-media mui-col-xs-3 on"){
						trade_leve=item.innerHTML;
					}
				});
			traderBond=tzdr.moneyUtils.reverseMoney(tzdr.moneyUtils.removeY(traderBond))
			trade_leve=tzdr.moneyUtils.reverseMoney(trade_leve);
			if(mui.isnull(traderBond)||mui.isnull(trade_leve)){
				mui.toast("系统繁忙，请刷新再试！");
				return;
			}
			if (mui.cacheUser.isLogin()){
				var futurePaySuc = plus.webview.getWebviewById("futurePaySuc.html");
				
				if(futurePaySuc){
					futurePaySuc.close();
				}
				mui.openWindow({
					url:"pay.html",
					id:"pay.html",
					extras:{
						traderBond:traderBond,
						businessType:0,
						trade_leve:trade_leve,
						pageNumber:"cn.html"
					}
				});
			}
			else
			{
				mui.openWindow({url:"../login/login.html",id:"login",extras:{backpageID:"cn"}});
			}
			
		};
		
	</script>
</head>
<body>
	<header class="mui-bar mui-bar-nav own-topbg">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" id="back"><i>返回</i></a>
		<h1 id="nav-title" class="mui-title">富时A50</h1>
		<a href="javascript:void(0);" class="top-tel" id="tran_info">操盘细则</a>
	</header>
<div class="mui-content ap_main" >
	<h5 class="ap_choosetitle"><span>选择手数：</span><b>可持仓的最大手数</b></h5>
	<ul class="mui-table-view mui-grid-view mui-grid-9" id="trade_num"style="border-bottom: 1px solid #E4E4E4;">
		
	</ul>
	<ul class="mui-table-view sc_listsc">
		<li class="mui-table-view-cell">
			<label>操盘保证金(¥)：</label>
			<span id="traderBond">¥27,750</span>
		</li>	
		<li class="mui-table-view-cell">
			<label>总操盘资金($)：</label>
			<span id="traderTotal">10,750美元</span>
		</li>
		<li class="mui-table-view-cell">
			<label>亏损平仓线($)：</label>
			<span id="lineLoss">10,450美元</span>
		</li>
	</ul>	
	<ul class="mui-table-view sc_listsc">
		<li class="mui-table-view-cell">
			<label>账户管理费(¥)：</label>
			<span id="manageFee">免费</span>
		</li>
		<li class="mui-table-view-cell">
			<div><label>交易手续费(¥)：</label></div>
			<div><span class="fontBlack">¥<i id="tranFees">58</i>/单边</span><span class="grayFontDiv">买入、卖出一手时各收取该数额（人民币）的交易手续费，结算时统一扣除。</span></div>
		</li>
	</ul>
	<ul class="mui-table-view sc_listsc sc_listscStyle">
		<li class="mui-table-view-cell">
			<div><label>投资标的：</label></div>
			<div><span>新华富时A50指数当期主力合约<i id="mainContract">CL1603</i></span></div>
		</li>			
		<li class="mui-table-view-cell">
			<div><label>交易时间：</label></div>
			<div><span class="fontBlack">9:05-16:30,17:05-02:00</span><span class="grayFontDiv">（注意：请不要在交易时间外持单，以免被系统强制平仓）</span></div>
		</li>
	</ul>
	<div id="buttomDiv">
		<span>总计：<i class="yellowFont">¥</i><i id="paymentMoney"></i></span>
		<button type="button" id="openPay" class="mui-btn  lg-btnlogin">提交操盘申请</button>
	</div>
	<div class=" AgreementList" >
		<p >提交申请表示阅读并同意<a href="javascript:void(0);" id="cn_info">《富时A50操盘合作协议》</a></p>
		<!--<p><i id="telservice">新手可向客服索取模拟操盘账号：<a href="#">400-180-1860</a></i></p>-->
	</div>
</div>
</body>
</html>
